package main

import (
	"3Party/DataStructure/hashtable"
	"fmt"
)

type stringValue struct {
	key   string
	value string
}

func (this *stringValue) Key() interface{} {
	return this.key
}

type uint32Value struct {
	key   uint32
	value string
}

func (this *uint32Value) Key() interface{} {
	return this.key
}

func main() {
	ht := hashtable.NewHashTable()
	if err := ht.Insert(&uint32Value{key: 588, value: "123588"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	if err := ht.Insert(&uint32Value{key: 885, value: "123885"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	if err := ht.Insert(&uint32Value{key: 34, value: "123885"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	if err := ht.Insert(&uint32Value{key: 57, value: "123885"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	if err := ht.Insert(&uint32Value{key: 23, value: "123885"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	if err := ht.Insert(&uint32Value{key: 88, value: "123885"}); err != nil {
		fmt.Printf("hashtable insert err:%v\n", err)
		return
	}

	ht.Dump(true)

	ht2 := hashtable.NewHashTable()
	if err := ht2.Insert(&stringValue{key: "asfas", value: "123588"}); err != nil {
		fmt.Printf("hashtable 2 insert err:%v\n", err)
		return
	}

	if err := ht2.Insert(&stringValue{key: "hbfa", value: "123588"}); err != nil {
		fmt.Printf("hashtable 2 insert err:%v\n", err)
		return
	}

	if err := ht2.Insert(&stringValue{key: "noji", value: "123588"}); err != nil {
		fmt.Printf("hashtable 2 insert err:%v\n", err)
		return
	}

	if err := ht2.Insert(&stringValue{key: "nuive", value: "123588"}); err != nil {
		fmt.Printf("hashtable 2 insert err:%v\n", err)
		return
	}

	if err := ht2.Insert(&stringValue{key: "vnie", value: "123588"}); err != nil {
		fmt.Printf("hashtable 2 insert err:%v\n", err)
		return
	}

	ht2.Dump(true)
}
